home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -screenplay- / hd_installers / -whdload- / whdload_dev / src / slave-examples / interphase.asm < prev    next >
Assembly Source File  |  1998-07-16  |  5KB  |  210 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    interphase.asm
  3. ;  :Contents.    Slave for "Interphase"
  4. ;  :Author.    Wepl
  5. ;  :Version.    $Id: interphase.asm 1.7 1998/06/27 23:50:34 jah Exp jah $
  6. ;  :History.    06.02.98 started
  7. ;        28.04.98 finished
  8. ;        02.05.98 flushcache inserted, now runs with cache enabled
  9. ;        15.06.98 savegame routine moved to external file
  10. ;  :Requires.    -
  11. ;  :Copyright.    Public Domain
  12. ;  :Language.    68000 Assembler
  13. ;  :Translator.    Barfly V2.9
  14. ;  :To Do.
  15. ;---------------------------------------------------------------------------*
  16.  
  17.     INCDIR    Includes:
  18.     INCLUDE    whdload.i
  19.  
  20.     IFD    BARFLY
  21.     OUTPUT    "wart:interphase/interphase.slave"
  22.     BOPT    O+ OG+                ;enable optimizing
  23.     BOPT    ODd- ODe-            ;disable mul optimizing
  24.     BOPT    w4-                ;disable 64k warnings
  25.     SUPER                    ;disable supervisor warnings
  26.     ENDC
  27.  
  28. ;============================================================================
  29.  
  30. .base        SLAVE_HEADER            ;ws_Security + ws_ID
  31.         dc.w    5            ;ws_Version
  32.         dc.w    WHDLF_Disk|WHDLF_NoError|WHDLF_EmulTrap|WHDLF_NoDivZero    ;ws_flags
  33.         dc.l    $80000            ;ws_BaseMemSize
  34.         dc.l    0            ;ws_ExecInstall
  35.         dc.w    _Start-.base        ;ws_GameLoader
  36.         dc.w    0            ;ws_CurrentDir
  37.         dc.w    0            ;ws_DontCache
  38. _keydebug    dc.b    0            ;ws_keydebug
  39. _keyexit    dc.b    $59            ;ws_keyexit = F10
  40.  
  41. ;============================================================================
  42.  
  43.     IFD    BARFLY
  44.         dc.b    "$VER: Interphase.Slave by Wepl "
  45.     DOSCMD    "WDate >T:date"
  46.     INCBIN    "T:date"
  47.         dc.b    0
  48.     ENDC
  49.     EVEN
  50.  
  51. ;============================================================================
  52. _Start    ;    A0 = resident loader
  53. ;============================================================================
  54. ;
  55. ;    Image format:
  56. ;    Disk 1        tracks 2-75 = 373760
  57. ;
  58. ;============================================================================
  59.  
  60.         lea    (_resload,pc),a1
  61.         move.l    a0,(a1)            ;save for later using
  62.  
  63.         moveq    #0,d0            ;offset
  64.         move.l    #$1c+$48c0,d1        ;size
  65.         moveq    #1,d2            ;disk
  66.         lea    $400,a0            ;destination
  67.         move.l    (_resload),a1
  68.         jsr    (resload_DiskLoad,a1)
  69.         
  70.         skip    6,$400+$98        ;dma on
  71.         ret    $400+$4532        ;vector init
  72.         patch    $400+$146,_1
  73.  
  74.         jmp    $400
  75.  
  76. _1        move.l    #$6400,d0        ;offset
  77.         move.l    #$1c+$545c6,d1        ;size
  78.         moveq    #1,d2            ;disk
  79.         move.l    $300,a0            ;destination
  80.         move.l    (_resload),a1
  81.         jsr    (resload_DiskLoad,a1)
  82.  
  83.         move.w    #$4e40,$400+$212    ;trap #0
  84.         lea    _2,a0
  85.         move.l    a0,$80
  86.         
  87.         jmp    $400+$1ae
  88.  
  89. _2        move.w    #500,$400+$129c        ;time to wait
  90.         patch    $400+$30a0,_int6c
  91.         
  92.         skip    $280-$26e,$400+$26e    ;drive stuff
  93.  
  94.         patch    $400+$2f0,_3
  95.  
  96.         jsr    $400+$114c        ;clr screen
  97.  
  98.         bsr    _waitvb
  99.         move.w    #$87d0,(_custom+dmacon)
  100.  
  101.         jsr    $400+$45e        ;original
  102.  
  103.         addq.l    #2,(2,a7)
  104.         rte
  105.  
  106. _int6c        subq.w    #1,$400+$129c
  107.         btst    #6,$bfe001
  108.         beq    .q
  109.         btst    #7,$bfe001
  110.         beq    .q
  111.         btst    #2,(_custom+potinp)
  112.         bne    .n
  113. .q        move.w    #-1,$400+$129c
  114. .n        move.w    #$20,(_custom+intreq)
  115. _rte        rte
  116.  
  117. _3        bsr    _waitvb
  118.         move.w    #$7fff,(_custom+intena)
  119.         move.w    #$7fff,(_custom+dmacon)
  120.         move.w    #$7fff,(_custom+intreq)
  121.     ;    sub.w    #10,$a08        ;ignore unwanted ports interrupts
  122.         pea    _keyint
  123.         move.l    (a7)+,$602
  124.         patch    $548a,$5a56        ;rn copylock
  125.         patch    $25f4,_savegame
  126.         patch    $2608,_loadgame
  127.  
  128.         move.l    (_resload),a0
  129.         jsr    (resload_FlushCache,a0)    ;to fix af if icache enabled
  130.  
  131.         lea    $400,a0
  132.         jmp    (a0)
  133.  
  134. ;--------------------------------
  135.  
  136. _keyint        movem.l    d0-d1/a1,-(a7)
  137.         lea    (_ciaa),a1
  138.         btst    #CIAICRB_SP,(ciaicr,a1)        ;check int reason
  139.         beq    .int2_exit
  140.         move.b    (ciasdr,a1),d0            ;read code
  141.         clr.b    (ciasdr,a1)            ;output LOW (handshake)
  142.         or.b    #CIACRAF_SPMODE,(ciacra,a1)    ;to output
  143.         not.b    d0
  144.         ror.b    #1,d0
  145.  
  146.         move.b    d0,$591
  147.         jsr    $a52
  148.  
  149.         cmp.b    (_keyexit),d0
  150.         beq    _exit
  151.         
  152.         cmp.b    #$5f,d0
  153.         bne    .1
  154.         eor.w    #$f16c,$775a            ;trainer (John Selck)
  155.         move.w    #$210,$4ec
  156. .1
  157.         moveq    #2-1,d1                ;wait because handshake min 75 µs
  158. .int2_w1    move.b    (_custom+vhposr),d0
  159. .int2_w2    cmp.b    (_custom+vhposr),d0        ;one line is 63.5 µs
  160.         beq    .int2_w2
  161.         dbf    d1,.int2_w1            ;(min=127µs max=190.5µs)
  162.  
  163.         and.b    #~(CIACRAF_SPMODE),(ciacra,a1)    ;to input
  164. .int2_exit    move.w    #INTF_PORTS,(intreq+_custom)
  165.         movem.l    (a7)+,d0-d1/a1
  166.         rte
  167.  
  168. ;--------------------------------
  169.  
  170. _loadgame    move.l    #100,d0
  171.         lea    $65000,a1        ;free mem for screen
  172.         bsr    _sg_load
  173.         move.w    #$4100,(_custom+bplcon0)
  174.         move.w    #320/8*3,(_custom+bpl1mod)
  175.     ;    move.l    #$00000eee,(color,a6)
  176.         moveq    #0,d2
  177.         rts
  178.  
  179. _savegame    move.l    #100,d0
  180.         lea    $65000,a1        ;free mem for screen
  181.         bsr    _sg_save
  182.         move.w    #$4100,(_custom+bplcon0)
  183.         move.w    #320/8*3,(_custom+bpl1mod)
  184.     ;    move.l    #$00000eee,(color,a6)
  185.         moveq    #0,d2
  186.         rts
  187.  
  188. ;--------------------------------
  189.  
  190. _waitvb        waitvb
  191.         rts
  192.  
  193. _exit        pea    TDREASON_OK
  194.         move.l    (_resload),-(a7)
  195.         add.l    #resload_Abort,(a7)
  196.         rts
  197.  
  198. ;--------------------------------
  199.  
  200. _resload    dc.l    0            ;address of resident loader
  201.  
  202. ;============================================================================
  203.  
  204.     INCLUDE    Sources:whdload/savegame.s
  205.  
  206. ;============================================================================
  207.  
  208.     END
  209.  
  210.